
package StackAlgorithm;

/**
 *
 * @author hazem
 */
public class PathStack implements StackInterface
{
	private Node top;
	private int size;

	public PathStack()
	{
		top = null;
		size = 0;

	}

	public boolean isEmpty()
	{
		return (size == 0);
	}

	public Object peek()
	{
		if (size == 0)

			return "";
		return top.getElement();

	}

	public Object pop()
	{
		if (isEmpty())
			return "";
		Node temp;
		temp = top;
		top = top.getNext();
		temp.setNext(null);
		size--;

		return temp.getElement();

	}

	public void push(Object item)
	{
		Node newNode = new Node(item, top);
		top = newNode;
		size++;
	}

	public int size()
	{

		return size;
	}

}
